<?php include_once("../../../common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once(ROOT_PATH_ . "/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once("../controller/data_add_schedule.php");                     // 当前页面的控制器 ?>



<body>


    <?
    //==============================================================================
    //这里开始才是平常开发需要注重的部分，其余的基本不用理会
    //==============================================================================
    ?>

    <div id="window">

            <!--标题设定-->
            <?php $page_title='套餐及产品配置信息';?>
            <?php include ROOT_PATH_ . '/controller/common/module/mod-page-title.php'; ?>





           <div class="detail-box">


               <ul class="detail-boxing">
                   <form id="data_form" method="post" class="layui-form"
                         action ="data_add_schedule_process.php?<? echo $url_parameter ?>"
                         enctype="multipart/form-data">

                       <input type="hidden"  name="product_nid" value="<? echo $data['nid']?>" >
                       <input type="hidden"  name="product_name" value="<? echo $data['title']?>" >
                       <input type="hidden"  name="startdate" value="<? echo $data['startdate']?>" >
                       <input type="hidden"  name="enddate" value="<? echo $data['enddate']?>" >


                       <table class="layui-table">
                            <thead>
                           <tr>
                               <th>套餐:<? echo $data['title'] ?></th>
                               <th>套餐类型数量：<? echo count($milk_checked_list)?></th>
                               <th>套餐产品数量: <? echo $data['amount'] ?></th>
                               <th>套餐日期:<? echo $data['startdate'] ?> - <? echo $data['enddate'] ?></th>
                           </tr>
                           <tr>
                               <th></th>
                               <th>已设置类型量：<? echo count(array_unique($milk_schdule_list_1darray))?></th>
                               <th>已设置产品量: <? echo count($milk_schdule_list_1darray)?></th>
                               <th></th>
                           </tr>

                           <tr>
                               <td colspan="4">
                                   <?foreach ($milk_checked_list as $key=>$value){?>
                                       【<? echo $value ?> ：
                                       <?  $count_values = array_count_values($milk_schdule_list_1darray);
                                       echo $count_123 = isset($count_values[$value]) ? $count_values[$value] : 0;
                                       ?>】
                                       &nbsp;&nbsp;&nbsp;&nbsp;
                                       <?;}?>

                               </td>
                           </tr>

                           </thead>

                       </table>



                       <!--标题设定-->
                       <?php $page_title='产品配置日程';?>
                       <?php include ROOT_PATH_ . '/controller/common/module/mod-page-title.php'; ?>




                       <?
                       if(empty(array_filter($milk_checked_list))){ ?>
                           <blockquote class="layui-elem-quote">请先为套餐添加包含的产品</blockquote>
                           <?exit;}?>


                       <table class="layui-table">
                           <thead>
                           <tr>
                               <th>序号</th>
                               <th>日期</th>
                               <th>日期</th>
                               <th>产品</th>
                           </tr>
                           </thead>
                           <tbody>


                  <?php
                  $i=1;
// 获取开始时间和结束时间
$start_date = isset($data['startdate']) ? strtotime($data['startdate']) : false;
$end_date = isset($data['enddate']) ? strtotime($data['enddate']) : false;

if ($start_date && $end_date && $start_date <= $end_date) {
    for ($time = $start_date; $time <= $end_date; $time += (24 * 60 * 60)) {
        $date_str = date("Y-m-d", $time);
        $date_week_str = date("w", $time);
?>
        <tr>
            <td><?echo $i;$i++?></td>
            <td><?= $date_str ?><input type="hidden" name="date[]" value="<?= $date_str ?>"></td>
            <td><?= $week_array[$date_week_str] ?></td>
            <td>
                <?foreach ($milk_checked_list as $key=>$value){?>
                    <input type="radio" class="layui-input"  name="milk[<?= $date_str ?>]"

                        <?if($milk_schdule_list_1darray[$date_str] == $value){echo "checked";}?>

                           value="<? echo $value ?>"
                           title="<? echo $value ?>">
                    <?;}?>
                <input type="radio" class="layui-input"
                    <?if($milk_schdule_list_1darray[$date_str] == ""){echo "checked";}?>
                       name="milk[<?= $date_str ?>]" value='' title='取消'"/>

            </td>

        </tr>
<?php
    }
} else {
?>
    <tr><td colspan="3">无效的日期范围</td></tr>
<?php
}
?>






                           </tbody>
                       </table>



<br/>
<br/>
<br/>
<br/>






                       <div class="function">

                           <button class="layui-btn"  lay-submit type="submit" >立即提交</button>
                           <input type="reset" class="layui-btn" value="重置"/>
                       </div>



                   </form>
               </ul>
           </div>
        </div>



        <?
        //==============================================================================
        //这里上面才是平常开发需要注重的部分，下面的基本不用理会，只有底部JS部分需要根据实际情况去加载
        //==============================================================================
        ?>



            </div>
            <!--detail-box end-->


</div>
<!--content端點01-->
<?
//==============================================================================
//这里上面才是平常开发需要注重的部分，下面的基本不用理会，只有底部JS部分需要根据实际情况去加载
//==============================================================================
?>





<br class="clearfloat"/>
<!--container-->
</div>




<!--底部栏-->
<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>
<!--返回顶部 按钮-->
<script type="text/javascript" src="/controller/common/asset/js/scrool_top.js"></script>


</body>
</html>
